import { contextBridge, ipcRenderer } from 'electron'

// 预加载脚本
window.addEventListener('DOMContentLoaded', () => {
  const replaceText = (selector: string, text: string) => {
    const element = document.getElementById(selector)
    if (element) element.innerText = text
  }

  for (const type of ['chrome', 'node', 'electron']) {
    replaceText(`${type}-version`, process.versions[type] as string)
  }
})

// 注册通信通道
contextBridge.exposeInMainWorld('electron', {
  ipcRenderer,
})
